package com.dq.controller;

import com.dq.pojo.VehicleList;
import com.dq.service.Impl.VehicleListServiceImpl;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import io.swagger.annotations.Api;

import javax.annotation.Resource;

/**
 * 序号(VehicleList)表控制层
 *
 * @author makejava
 * @since 2024-01-18 11:56:08
 */
@RestController
@RequestMapping("/vehicleList")
@Api(value = "(VehicleList)",tags = "(VehicleList)接口API")
public class VehicleListController {
    /**
     * 服务对象
     */
    @Resource
    private VehicleListServiceImpl vehicleListServiceImpl;

    /**
     * 一次性全部查询
     *
     * @return 查询结果
     */
//    @GetMapping("/selectAll")
    public Map<String, Object> selectAll() {
        return vehicleListServiceImpl.selectAll();
    }

    /**
     * 分页查询
     *
     * @param vehicleList 筛选条件
     * @param page        要查询第几页
     * @param limit       每页显示多少条
     * @return 查询结果
     */
    @GetMapping("")
    public Map<String, Object> selectByLimit(@RequestParam String search_1,@RequestParam String search_2,@RequestParam String search_3,@RequestParam int page, @RequestParam int limit) {
        //@RequestParam String vehicleNo,@RequestParam String vehicleType,@RequestParam String vehicleStatus,
        VehicleList vehicleList = new VehicleList();
        vehicleList.setVehicleNo(search_1);
        vehicleList.setVehicleType(search_2);
        vehicleList.setVehicleStatus(search_3);
//        vehicleList.setVehicleType(vehicleType);
//        vehicleList.setVehicleStatus(vehicleStatus);
        return vehicleListServiceImpl.selectByLimit(vehicleList, page, limit);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    /*@GetMapping("/selectById")*/
    public Map<String, Object> selectById(@RequestParam Integer id) {
        return vehicleListServiceImpl.selectById(id);
    }

    /**
     * 新增数据
     *
     * @param vehicleList 实体
     * @return 新增结果
     */
    @PostMapping("")
    public Map<String, Object> insert(@RequestBody VehicleList vehicleList) {
        return vehicleListServiceImpl.insert(vehicleList);
    }

    /**
     * 编辑数据
     *
     * @param vehicleList 实体
     * @return 编辑结果
     */
    @PutMapping("")
    public Map<String, Object> updateById(@RequestBody VehicleList vehicleList) {
        return vehicleListServiceImpl.updateById(vehicleList);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/{id}")
    public Map<String, Object> deleteById(@PathVariable Integer id) {
        return vehicleListServiceImpl.deleteById(id);
    }

}

